<?php
//require_once('./db.php');

$sql = "SELECT * FROM `job_group` WHERE `start_date` < NOW() AND `start_date` != '0000-00-00 00:00:00' AND `status` < 4";
$q = $db->runSQL($sql);

while ($job = $db->loadObject($q)) {
	$update = "UPDATE `job_group` SET `status` = 12 WHERE `gid` = ".$job->gid;
	$db->runSQL($update);
	
	$message = "No action taken, job order is now closed.";
	$messageSql = "INSERT INTO `conversation` (`jid`, `uid`, `text`, `postdate`, `type`, `paid`, `payment`) VALUES (".$job->gid.", 0, '".$message."', NOW(), 7, 0, 0)";
	$db->runSQL($messageSql);
}

?>